package com.wolves.career.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wolves.career.entity.JobOpportunityCompany;
import com.wolves.career.mapper.JobOpportunityCompanyMapper;
import com.wolves.career.service.JobOpportunityCompanyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 麦翔盛
 * @since 2021-10-23
 */
@Service
public class JobOpportunityCompanyServiceImpl extends ServiceImpl<JobOpportunityCompanyMapper, JobOpportunityCompany> implements JobOpportunityCompanyService {
    /**
     * name,region,telephone,email，create_time,update_time
     *
     * @param company
     * @return
     */
    @Override
    public QueryWrapper<JobOpportunityCompany> queryJobOpportunity(JobOpportunityCompany company) {
        if (company == null) {
            return null;
        }
        //获取需要的信息
        String name = company.getName();
        String region = company.getRegion();
        String telephone = company.getTelephone();
        String email = company.getEmail();
        Date createTime = company.getCreateTime();
        Date updateTime = company.getUpdateTime();
        //创建条件查询信息
        QueryWrapper<JobOpportunityCompany> queryWrapper = new QueryWrapper<>();
        //封装条件
        if (!StringUtils.isEmpty(name)) {
            //模糊查询公司名称
            queryWrapper.like("name", name);
        }
        if (!StringUtils.isEmpty(region)) {
            queryWrapper.eq("region", region);
        }
        if (!StringUtils.isEmpty(telephone)) {
            queryWrapper.eq("telephone", telephone);
        }
        if (!StringUtils.isEmpty(email)) {
            queryWrapper.eq("email", email);
        }
        if (!StringUtils.isEmpty(updateTime)) {
            queryWrapper.lt("update_time", updateTime);
        }
        if (!StringUtils.isEmpty(createTime)) {
            queryWrapper.gt("create_time", createTime);
        }
        return queryWrapper;
    }

}
